/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package boundary.report;

import net.sf.jasperreports.engine.JRDataSource;
import net.sf.jasperreports.engine.JRException;
import net.sf.jasperreports.engine.JRField;
import entity.*;

/**
 *
 * @author JAVIER
 */
public class SampleDataSource implements JRDataSource {
    
    public SampleDataSource(Sample ser){
        service = ser;
    }

    private Sample service = new Sample();
    private int sampleactually = -1;


    public Object getFieldValue(JRField jrf) throws JRException
    {
        Object valor = null;
        Test test = null;
        DatabaseTest dbt = null;

        if ("analisis".equals(jrf.getName()))
        {
            test = (Test)service.getTests().get(sampleactually);
            dbt = (DatabaseTest)test.getDatabaseTest();
            valor = dbt.getName();
        }
        else if ("precioanalisis".equals(jrf.getName()))
        {
            test = (Test)service.getTests().get(sampleactually);
            dbt = (DatabaseTest)test.getDatabaseTest();
            valor = dbt.getPrice();
        }
        
        return valor;
    }

    public boolean next() throws JRException
    {
        return ++sampleactually < service.getTests().size();
    }
    
}
